package com.kaifamiao.www.ioDemo.do0923;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

public class ObjectInputStreamDemo2 {
    public static void main(String[] args) {
        /**
         * 对象序列化
         */

        try (
                FileOutputStream fos = new FileOutputStream("E:\\kaifamiao\\workspace\\idea--space\\io\\Student1.txt");
                ObjectOutputStream os = new ObjectOutputStream(fos);
                ){
            Student stu = new Student("张三楠",88.88,"男");
            os.writeObject(stu);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
